/*
package yz.com.javautil.test;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import java.util.HashMap;
import java.util.Map;

*/
/**
 * @author hyx
 * @since 2020/7/10
 * 行政区划和运营商代码
 * 翻译热点入库数据机号归属地
 *//*

@Component
public class AttrCodeAndOperators {

    private static String attrRootType = "gsddm";
    private static String operatRootType = "yys";
    @Autowired
    DataSourceManagent dataSourceManagent;

    public Map<String, Object> addressTranslation(String attribution) {
        Map<String, Object> map = new HashMap<>(2);
        //设置归属地和运营商的默认值
        String attrcode = "-1";
        String operator = "-1";

        if (StringUtils.isNotBlank(attribution)) {
            String operatorChinese = "";
            String attrName = "";
            //正常数据处理，首先识别运营商，再识别行政区划
            if (attribution.endsWith("移动") || attribution.endsWith("联通") || attribution.endsWith("电信")) {
                operatorChinese = attribution.substring(attribution.length() - 2);
                if (attribution.length() > 2) {
                    attrName = attribution.substring(0, attribution.length() - 2);
                }
            } else {

                if ("中国香港".equals(attribution) || "中国澳门".equals(attribution) || "中国台湾".equals(attribution)) {
                    attrName = attribution.substring(attribution.length() - 2, attribution.length());
                } else {
                    if (attribution.contains("境外")) {
                        if ("境外".equals(attribution)) {
                            attrName = attribution;
                        } else {
                            attrName = attribution.substring(attribution.indexOf("_") + 1, attribution.length());
                        }
                    } else {
                        attrName = attribution;
                    }
                }
            }

            for (EnumeManageEntity entity : dataSourceManagent.getEnumeManageMap(operatRootType).values()) {
                if (operatorChinese.equalsIgnoreCase(entity.getName())) {
                    operator = entity.getCode();
                }
            }
            for (EnumeManageEntity entity : dataSourceManagent.getEnumeManageMap(attrRootType).values()) {
                if (attrName.equalsIgnoreCase(entity.getName())) {
                    attrcode = entity.getCode();
                }
            }
        }
        map.put("attrcode",attrcode);
        map.put("operator",operator);
        return map;
    }

    */
/**
     * 根据归属地编码获取归属地
     * @param attrcode
     * @return
     *//*

    public String getAttribution(String attrcode){
        String attrStr = "";
        if(StringUtils.isBlank(attrcode)||"-1".equals(attrcode)){
            attrStr = "";
        }else{
            if(attrcode.length()==2){
                //省份补全
                attrcode+="0000";
            }
            EnumeManageEntity entity = dataSourceManagent.getEnumeManage(attrRootType, attrcode);
            if(entity!=null){
                attrStr = entity.getName();
            }else{
                attrStr = "其他";
            }
        }
        return attrStr;
    }

    public String getOperator(String operator){
        String attrStr = "";
        if(StringUtils.isBlank(operator)||"-1".equals(operator)){
            attrStr = "";
        }else{
            EnumeManageEntity entity = dataSourceManagent.getEnumeManage(operatRootType, operator);
            if(entity!=null){
                attrStr = entity.getName();
            }else{
                attrStr = "";
            }

        }
        return attrStr;
    }
}
*/
